package com.ylcode.libback.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ylcode.libback.mapper.EmployeeMapper;
import com.ylcode.libback.model.pojo.Book;
import com.ylcode.libback.model.pojo.Employee;
import com.ylcode.libback.service.EmployeeService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {
    @Override
    public List<Employee> queryEmpByNameOrUsername(String param) {
        LambdaQueryWrapper<Employee> employeeLambdaQueryWrapper = new LambdaQueryWrapper<>();
        employeeLambdaQueryWrapper.eq(Employee::getName, param);
        List<Employee> list = this.list(employeeLambdaQueryWrapper);
        if (list.size() == 0) {
            employeeLambdaQueryWrapper.eq(Employee::getUsername, param);
            list = this.list(employeeLambdaQueryWrapper);
        }
        if (list.size() != 0) {
            return list;
        }
        return null;
    }
}
